﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;
using System.IO;

namespace SohuWeb.Models {
    public class Compute {
        public void ImportCSVAttendance(DateTime dt) {

            string csvPath = dt.ToString("yyyy-MM-dd", DateTimeFormatInfo.InvariantInfo);
            Config conf = new Config();
            if (conf.CSVPath.EndsWith("\\")) {
                csvPath = conf.CSVPath + csvPath + ".csv";
            } else {
                csvPath = conf.CSVPath + "\\" + csvPath + ".csv";
            }

            if (!File.Exists(csvPath)) {
                // TODO:add a log
                return;
            }

            using (FileStream fs = new FileStream(csvPath, FileMode.Open))
            using (StreamReader sr = new StreamReader(fs)) {
                string sLine;
                while ((sLine = sr.ReadLine()) != null) {
                    string[] items = sLine.Split(new char[] { ',' });
                    if (items.Length != 6) {
                        // TODO:add a log
                        continue;
                    }
                }
            }
        }
    }
}